package com.sample.livewallpaperdemo;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ViewGroup;

import com.sample.livewallpaperdemo.widget.TimeWeatherRenderer;

import org.rajawali3d.view.ISurface;
import org.rajawali3d.view.SurfaceView;
import org.rajawali3d.view.TextureView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // showEarth();
        // showTest();
        // showObj();
        // showAwd();
        // showPlane();
        showWidget();
    }

    public void showWidget() {
        final TextureView surface = (TextureView) findViewById(R.id.textureview);
        surface.setFrameRate(60.0);
        surface.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);
        //surface.setTransparent(true);

        TimeWeatherRenderer renderer = new TimeWeatherRenderer(this);
        surface.setSurfaceRenderer(renderer);
    }

    public void showPlane() {
        final TextureView surface = (TextureView) findViewById(R.id.textureview);
        surface.setFrameRate(60.0);
        surface.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);
        //surface.setTransparent(true);

        PlaneRenderer renderer = new PlaneRenderer(this);
        surface.setSurfaceRenderer(renderer);
    }

    public void showAwd() {
        final TextureView surface = (TextureView) findViewById(R.id.textureview);
        surface.setFrameRate(60.0);
        surface.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);
        //surface.setTransparent(true);

        AwdRenderer renderer = new AwdRenderer(this);
        surface.setSurfaceRenderer(renderer);
    }

    public void showObj() {
        final TextureView surface = (TextureView) findViewById(R.id.textureview);
        surface.setFrameRate(60.0);
        surface.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);
        //surface.setTransparent(true);

        ObjRenderer renderer = new ObjRenderer(this);
        surface.setSurfaceRenderer(renderer);
    }

    public void showTest() {
        final TextureView surface = (TextureView) findViewById(R.id.textureview);
        surface.setFrameRate(60.0);
        surface.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);
        //surface.setTransparent(true);

        TestRenderer renderer = new TestRenderer(this);
        surface.setSurfaceRenderer(renderer);
    }

    public void showEarth() {
        final SurfaceView surface = new SurfaceView(this);
        surface.setFrameRate(60.0);
        surface.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);

        // Add mSurface to your root view
        addContentView(surface, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT));

        EarthRenderer renderer = new EarthRenderer(this);
        surface.setSurfaceRenderer(renderer);
    }
}
